<!DOCTYPE html>
<html lang="en">
<head>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title><?=$title?></title>
    <link rel="stylesheet" href="/mobile/css/reset.css">
    <link rel="stylesheet" href="/mobile/css/mui.min.css">
    <link rel="stylesheet" href="/mobile/css/dropload.css">
    <script src="/mobile/js/flexible_css.debug.js"></script>
    <script src="/mobile/js/flexible.debug.js"></script>
    <link rel="stylesheet" href="/mobile/css/main_train.css">

</head>
<body id="test" style="height: auto;">
<div id="back-btn-wrap">
    <a class="back-btn" href="javascript:void(0)"></a>论坛发帖<a href="/mobile/society/add" class="btn-edit mui-icon mui-icon-compose"></a>
</div>

<div class="content-main" id="forumListWrap">
    <ul id="gr-forum-list" data-page="">
    </ul>
</div>
<script src="/mobile/js/jquery.min.js"></script>
<script src="/mobile/js/dropload.js"></script>
<script src="/mobile/js/common.js"></script>
<script src="/mobile/js/mui.min.js"></script>
<script src="/mobile/js/jrrpc.js"></script>

<script>

    function backSociety(){
        location.href = 'home?token='+iService.getAppParam().token;
    }

    $('.back-btn').on('click',function(){
        backSociety();
    });

    $(function() {
        mui.init(
           /*     {
            pullRefresh : {
                container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
                down : {
                    height:50,//可选,默认50.触发下拉刷新拖动距离,
                    auto: false,//可选,默认false.首次加载自动下拉刷新一次
                    contentdown : "下拉可以刷新",//可选，在下拉可刷新状态时，下拉刷新控件上显示的标题内容
                    contentover : "释放立即刷新",//可选，在释放可刷新状态时，下拉刷新控件上显示的标题内容
                    contentrefresh : "正在刷新...",//可选，正在刷新状态时，下拉刷新控件上显示的标题内容
                    offset:100, //可选 默认0px,下拉刷新控件的起始位置
                    callback :refreshPage //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
                }
            }
        }*/
        );
        var token = iService.getAppParam();
        var page = 1;
        var forumListWrap = $('#forumListWrap');

        function getNowPage(page,me){
            var param = {
                postData:'Society/lists',
                data:{
                    page:page
                }
            };
            $.extend(param.data,token);
            $.JsonRpc(param,function(result){
                console.log(result);
                if(!forumListWrap.attr('data-page')){
                    forumListWrap.attr('data-page',result.data.count);
                }
                var data = result.data.lists;
                if(!data.length&&page==1){
                    if(me){
                        me.resetload();
                    }
                    $('.dropload-noData').html('暂无数据');
                }else {
                    $.each(data,function(i){
                        $(
                            '<li class="item clearfix">'+
                            '<a href="/mobile/society/detail?sid='+data[i].sid+'">'+
                            '<div class="avatar-wrap fl">'+
                            '<img class="avatar" src="'+data[i].avatar+'" alt="">'+
                            '</div>'+
                            '<div class="list-right-wrap">'+
                            '<h3 class="clearfix">'+data[i].title+'</h3>'+
                            '<p class="tips-wrap clearfix">'+
                            '<span>'+data[i].nickname+'</span>'+
                            '<b>'+String(data[i].createtime).slice(0,10)+'</b>'+
                            '<i class="fr mui-icon mui-icon-chatbubble comment-num">'+data[i].comment+'</i>'+
                            '</p>'+
                            '</div>'+
                            '</a>'+
                            '</li>'
                        ).appendTo('#gr-forum-list');
                    });
                    if(me){
                        me.resetload();
                    }
                }
            },me);
        }

//        getNowPage(page);
        forumListWrap.dropload({
//                滑动区域
                scrollArea: window,
//                autoLoad:false,
//                    定义上方样式
                domUp: {
                    domClass: "dropload-up",
                    domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>',
                    domUpdate: '<div class="dropload-update">↑释放更新</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>刷新中...</div>'},
//                定义下方样式
                domDown: {
                    domClass: "dropload-down",
                    domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                    domNoData: '<div class="dropload-noData">已加载全部</div>'
                },
                distance: 50,
                threshold: "",
                loadUpFn: function(me){
                    window.location.reload();
//                    重置dropload
                    me.resetload();
                },
//                上滑加载更多方法
                loadDownFn: function(me){
                    if(page==1){
                        getNowPage(page,me);
                        page +=1;
                    }else if(page<=Math.ceil(forumListWrap.attr('data-page')/3)
                        ){
                        getNowPage(page,me);
                        page +=1;
                    }else {
                        me.lock();//没有更多数据
                        me.noData();//没有更多数据
                        me.resetload();
                    }
                }
            });
        $.get('https://www.wzxaini9.cn/api/flow/index/id/11', function (data) {
            console.log($.parseJSON(data));
        })
    });
</script>
</body>
</html>












